﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.Linq;

namespace Radar {
    /// <summary>
    /// Summary description for RadarLocal
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class RadarLocal : System.Web.Services.WebService {

        private string connString = @"Data Source=localhost;Initial Catalog=Radar;Integrated Security=true";

        [WebMethod]
        public void StoreCapture(Capture c, List<Image> images) {
            DataContext dc = new DataContext(connString);
            Table<Capture> tc = dc.GetTable<Capture>();
            tc.InsertOnSubmit(c);
            dc.SubmitChanges();
            images.ForEach(i => i.captureId = c.id);
            dc = new DataContext(connString);
            Table<Image> ti = dc.GetTable<Image>();
            ti.InsertAllOnSubmit(images);
            dc.SubmitChanges();
        }
    }
}
